package com.digital.smartgrow.controller.export;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.entity.export.ExportApprove;
import com.digital.smartgrow.service.export.ExportApproveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 专家审批 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-09-16
 */
@Api(tags = "专家审批")
@RestController
@RequestMapping("${context.prefix}/syc/exportApprove")
public class ExportApproveController {

    @Autowired
    private ExportApproveService exportApproveService;

//    @ApiOperation(value = "专家审批-分页查询")
//    @PostMapping("/list")
//    public Object getListByPage(@RequestBody ExportApprovePageDTO exportApprovePageDTO){
//        return exportApproveService.getListByPage(exportApprovePageDTO);
//    }

    @ApiOperation(value = "专家审批-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return exportApproveService.getInfo(id);
    }

    @ApiOperation(value = "专家审批-删除")
    @DeleteMapping("/{id}")
    public Object removeById(@PathVariable Integer id){
      if (id == null) return Result.fail("id不能为空");
      return exportApproveService.removeById(id);
    }
    @ApiOperation(value = "专家审批-新增")
    @PostMapping()
    public Object add( @RequestBody  ExportApprove exportApprove){
       return exportApproveService.save(exportApprove);
    }

    @ApiOperation(value = "专家审批-编辑")
    @PutMapping()
    public Object edit(@RequestBody ExportApprove exportApprove){
    if (exportApprove==null||exportApprove.getId() == null)
       return Result.fail("id不能为空");
       return exportApproveService.updateById(exportApprove);
    }
}
